<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body class="d1">

</body>
<script type="text/javascript">
  var a = ["red", "orange", "yelllow", "green", "cyan", "blue", "purple"];
  var num = 0;
  function b() {
    document.getElementsByClassName("d1")[0].style.background = a[num];
    num++;
    if (num > 7) {
    }
  }
  setInterval(function () { b() }, 500);

</script>

</html>